<!DOCTYPE html>
<html>

{include file='public/header'}

<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="javascript:void(0)">首页</a>
            <a href="javascript:void(0)">CPS联盟统计</a>
            <a><cite>推广主</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" id="reload" title="刷新">
            <i class="layui-icon" style="line-height:30px"><i class="iconfont">&#xe6aa;</i></i>
        </a>
    </div>
    <div class="x-body">
        <div class="layui-row">
            <form class="layui-form">
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">公众号ID：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="id" placeholder="请输入公众号ID" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <button class="layui-btn" style="margin-left: 10px;" lay-submit lay-filter="searchList">搜索</button>
                <button type="reset" id="resetList" class="layui-btn layui-btn-primary">重置</button>
            </form>
        </div>
        <table id="mainList" lay-filter="mainList"></table>
    </div>
    <script type="text/html" id="tbBar">
        <a class="layui-btn layui-btn-xs" lay-event="revenue">查看收入</a>
        <a class="layui-btn layui-btn-xs" lay-event="user">查看用户</a>
    </script>
    <script>
        let params = {
            elem: '#mainList'
            , url: '/admin/alliance/mainList' //数据接口
            , id: 'mainList'
            , page:true
            , cols: [[ //表头
                { field: 'id', title: '公众号ID', width: 120, sort: true }
                , { field: 'name', title: '公众号名称' }
                , { field: 'created_at', title: '创建时间', templet: function (d) {
                        return dayjsFormat(d.created_at)
                    } 
                }
                , { toolbar: '#tbBar', title: '操作',width:200}
            ]]
        }
        tableList(params)
        layui.use('table', function () {
            var table = layui.table;
           
            table.on('tool(mainList)', function (obj) {
                var event = obj.event;
                if (event === 'revenue') {
                    x_admin_show('查看收入', `./revenue.html?id=${obj.data.id}`, 1100, 700);
                } else if (event === 'user') {
                    x_admin_show('查看用户', `./user.html?id=${obj.data.id}`, 1100, 700);
                }
            });
        });
    </script>
</body>

</html>